#include <stdlib.h>
#include "EmployeeInfo.h"
#include "Config.h"
#include "GCUtils.h"


EmployeeInfo* EmployeeInfo_New(
	double basicSalary,
	double allowance,
	double jobAllowance,
	double helpAllowance,
	double houseAllowance,
	double trafficAllowance,
	double houseRent,
	double deposit,
	double dues)
{
	double tax = 0;
	EmployeeInfo* info = (EmployeeInfo*)malloc(sizeof(EmployeeInfo));
	gc_new_object(info);
	info->basicSalary = basicSalary;
	info->allowance = allowance;
	info->jobAllowance = jobAllowance;
	info->helpAllowance = helpAllowance;
	info->houseAllowance = houseAllowance;
	info->trafficAllowance = trafficAllowance;
	info->shouldSalary = basicSalary + allowance + jobAllowance + helpAllowance + houseAllowance + trafficAllowance;
	info->houseRent = houseRent;
	info->deposit = deposit;
	info->dues = dues;
	if(info->shouldSalary > 800 && info->shouldSalary < 1000)
	{
		tax = (info->shouldSalary-800) * 0.05;
	}
	if(info->shouldSalary >1000 && info->shouldSalary < 5000)
	{
		tax = (1000-800)*0.05 + (info->shouldSalary - 1000)*0.1; 
	}
	if(info->shouldSalary >5000)
	{
		tax = (1000-800)*0.05 + (5000-1000)*0.1 + (info->shouldSalary - 5000)*0.2;
	}
	info->tax = tax;
	info->excludeSalary = info->houseRent + info->deposit + info->dues + info->tax;
	info->actualSalary = info->shouldSalary - info->excludeSalary;
	info->isDeleted = FALSE;
	return info;
}